<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								房间编号：<input type="text" name="code"/>
							</li>

							<li>
								类型：<select name="type" th:with="type=${@dict.getType('room_type')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
										th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								状态：<select name="status" th:with="type=${@dict.getType('room_status')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
										th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								楼层：<input type="text" name="floor"/>
							</li>

							<li>
								等级：<select name="level" th:with="type=${@dict.getType('room_level')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
										th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:guestRoom:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:guestRoom:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:guestRoom:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:guestRoom:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:guestroom:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:guestroom:remove')}]];
		var types = [[${@dict.getType('room_type')}]];
		var roomStatus = [[${@dict.getType('room_status')}]];
		var levels = [[${@dict.getType('room_level')}]];
		var prefix = ctx + "system/guestRoom";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "客房",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '',
					visible: false
				},
				{
					field : 'code', 
					title : '房间编号',
					sortable: true
				},
				{
					field: 'type',
					title: '类型',
					sortable: true,
					align: 'center',
					formatter: function (value, row, index) {
						return $.table.selectDictLabel(types, value);
					}
				},
				{
					field: 'status',
					title: '状态',
					sortable: true,
					align: 'center',
					formatter: function (value, row, index) {
						return $.table.selectDictLabel(roomStatus, value);
					}
				},
				{
					field : 'floor', 
					title : '楼层',
					sortable: true
				},
				{
					field : 'price', 
					title : '价格',
					sortable: true
				},
				{
					field: 'level',
					title: '等级',
					sortable: true,
					align: 'center',
					formatter: function (value, row, index) {
						return $.table.selectDictLabel(levels, value);
					}
				},
				{
					field : 'introduce', 
					title : '介绍',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
						if(row.status === 0){
							actions.push('<a class="btn btn-info btn-xs" href="#" onclick="reserve(\'' + row.id + '\')"><i class="fa fa-key"></i>预定</a>&nbsp;');
						}
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

		function reserve(roomId) {
			var url = ctx + "system/customer/reserve/" + roomId;
			$.modal.open("房间预定", url, '800', '300');
		}
    </script>
</body>
</html>